<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Digest::MD5 - Perl interface to the MD5 Algorithm - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Digest::MD5">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Digest::MD5.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Digest::MD5">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Digest::MD5">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Digest::MD5">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Digest::MD5">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Digest::MD5">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Digest::MD5">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Digest::MD5">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Digest::MD5">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Digest::MD5">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Digest::MD5">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Digest::MD5">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Digest::MD5">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Digest::MD5">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Digest::MD5">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Digest::MD5">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Digest::MD5">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Digest::MD5">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Digest::MD5">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Digest::MD5">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Digest::MD5">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Digest::MD5">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Digest::MD5">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Digest::MD5">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Digest::MD5">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Digest::MD5">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Digest::MD5">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Digest::MD5">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Digest::MD5">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Digest::MD5">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Digest::MD5">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Digest::MD5">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Digest::MD5">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Digest::MD5">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Digest::MD5">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Digest::MD5">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Digest::MD5">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Digest::MD5">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Digest::MD5">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Digest::MD5">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Digest::MD5">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Digest::MD5">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Digest::MD5">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Digest::MD5">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Digest::MD5">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Digest::MD5">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Digest::MD5">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Digest::MD5">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Digest::MD5">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Digest::MD5">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Digest::MD5">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Digest::MD5">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Digest::MD5">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Digest::MD5">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Digest::MD5">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Digest::MD5">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Digest::MD5">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Digest::MD5">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Digest::MD5">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Digest::MD5">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Digest::MD5">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Digest::MD5">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Digest::MD5">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Digest::MD5">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Digest::MD5">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Digest::MD5">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Digest::MD5">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Digest::MD5">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Digest::MD5">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Digest::MD5">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Digest::MD5">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Digest::MD5">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Digest::MD5">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Digest::MD5">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Digest::MD5">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Digest::MD5">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Digest::MD5">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Digest::MD5">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Digest::MD5">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Digest::MD5">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Digest::MD5">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Digest::MD5.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Digest::MD5">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Digest::MD5">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Digest::MD5">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Digest::MD5">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Digest::MD5">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Digest::MD5">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Digest::MD5">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Digest::MD5">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Digest::MD5">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Digest::MD5">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Digest::MD5">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Digest::MD5">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Digest::MD5">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Digest::MD5">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Digest::MD5">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Digest::MD5">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Digest::MD5">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Digest::MD5">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Digest::MD5">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Digest::MD5">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Digest::MD5">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Digest::MD5">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Digest::MD5">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Digest::MD5">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Digest::MD5">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Digest::MD5">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Digest::MD5">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Digest::MD5">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Digest::MD5">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Digest::MD5">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Digest::MD5">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Digest::MD5">5.35.1</a>
          <a class="dropdown-item active" href="./Digest::MD5.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Digest::MD5.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Digest::MD5.html">Digest::MD5</a>
          <div id="more">
            (<a href="./Digest::MD5.txt">source</a>,
            <a href="https://metacpan.org/pod/Digest::MD5">CPAN</a>)
          </div>
            <div id="moduleversion">version 2.58</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#FUNCTIONS">FUNCTIONS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#METHODS">METHODS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#EXAMPLES">EXAMPLES</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#SEE-ALSO">SEE ALSO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#COPYRIGHT">COPYRIGHT</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Digest::MD5.html#AUTHORS">AUTHORS</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Digest::MD5.html#NAME">#</a>NAME</h1>

<p>Digest::MD5 - Perl interface to the MD5 Algorithm</p>

<h1 id="SYNOPSIS"><a class="permalink" href="./Digest::MD5.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<pre><code># Functional style
use Digest::MD5 qw(md5 md5_hex md5_base64);

$digest = md5($data);
$digest = md5_hex($data);
$digest = md5_base64($data);

# OO style
use Digest::MD5;

$ctx = Digest::MD5-&gt;new;

$ctx-&gt;add($data);
$ctx-&gt;addfile($file_handle);

$digest = $ctx-&gt;digest;
$digest = $ctx-&gt;hexdigest;
$digest = $ctx-&gt;b64digest;</code></pre>

<h1 id="DESCRIPTION"><a class="permalink" href="./Digest::MD5.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>The <code>Digest::MD5</code> module allows you to use the RSA Data Security Inc. MD5 Message Digest algorithm from within Perl programs. The algorithm takes as input a message of arbitrary length and produces as output a 128-bit &quot;fingerprint&quot; or &quot;message digest&quot; of the input.</p>

<p>Note that the MD5 algorithm is not as strong as it used to be. It has since 2005 been easy to generate different messages that produce the same MD5 digest. It still seems hard to generate messages that produce a given digest, but it is probably wise to move to stronger algorithms for applications that depend on the digest to uniquely identify a message.</p>

<p>The <code>Digest::MD5</code> module provide a procedural interface for simple use, as well as an object oriented interface that can handle messages of arbitrary length and which can read files directly.</p>

<h1 id="FUNCTIONS"><a class="permalink" href="./Digest::MD5.html#FUNCTIONS">#</a>FUNCTIONS</h1>

<p>The following functions are provided by the <code>Digest::MD5</code> module. None of these functions are exported by default.</p>

<dl>

<dt id="md5($data,...)"><a class="permalink" href="./Digest::MD5.html#md5($data,...)">#</a><a id="md5"></a><a id="md5-data"></a>md5($data,...)</dt>
<dd>

<p>This function will concatenate all arguments, calculate the MD5 digest of this &quot;message&quot;, and return it in binary form. The returned string will be 16 bytes long.</p>

<p>The result of md5(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) will be exactly the same as the result of md5(&quot;abc&quot;).</p>

</dd>
<dt id="md5_hex($data,...)"><a class="permalink" href="./Digest::MD5.html#md5_hex($data,...)">#</a><a id="md5_hex"></a><a id="md5_hex-data"></a>md5_hex($data,...)</dt>
<dd>

<p>Same as md5(), but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: &#39;0&#39;..&#39;9&#39; and &#39;a&#39;..&#39;f&#39;.</p>

</dd>
<dt id="md5_base64($data,...)"><a class="permalink" href="./Digest::MD5.html#md5_base64($data,...)">#</a><a id="md5_base64"></a><a id="md5_base64-data"></a>md5_base64($data,...)</dt>
<dd>

<p>Same as md5(), but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: &#39;A&#39;..&#39;Z&#39;, &#39;a&#39;..&#39;z&#39;, &#39;0&#39;..&#39;9&#39;, &#39;+&#39; and &#39;/&#39;.</p>

<p>Note that the base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md5 digests you might want to append the redundant string &quot;==&quot; to the result.</p>

</dd>
</dl>

<h1 id="METHODS"><a class="permalink" href="./Digest::MD5.html#METHODS">#</a>METHODS</h1>

<p>The object oriented interface to <code>Digest::MD5</code> is described in this section. After a <code>Digest::MD5</code> object has been created, you will add data to it and finally ask for the digest in a suitable format. A single object can be used to calculate multiple digests.</p>

<p>The following methods are provided:</p>

<dl>

<dt id="$md5-=-Digest::MD5-&gt;new"><a class="permalink" href="./Digest::MD5.html#$md5-=-Digest::MD5-%3Enew">#</a><a id="md5-Digest::MD5-new"></a>$md5 = Digest::MD5-&gt;new</dt>
<dd>

<p>The constructor returns a new <code>Digest::MD5</code> object which encapsulate the state of the MD5 message-digest algorithm.</p>

<p>If called as an instance method (i.e. $md5-&gt;new) it will just reset the state the object to the state of a newly created object. No new object is created in this case.</p>

</dd>
<dt id="$md5-&gt;reset"><a class="permalink" href="./Digest::MD5.html#$md5-%3Ereset">#</a><a id="reset"></a><a id="md5-reset"></a>$md5-&gt;reset</dt>
<dd>

<p>This is just an alias for $md5-&gt;new.</p>

</dd>
<dt id="$md5-&gt;clone"><a class="permalink" href="./Digest::MD5.html#$md5-%3Eclone">#</a><a id="clone"></a><a id="md5-clone"></a>$md5-&gt;clone</dt>
<dd>

<p>This a copy of the $md5 object. It is useful when you do not want to destroy the digests state, but need an intermediate value of the digest, e.g. when calculating digests iteratively on a continuous data stream. Example:</p>

<pre><code>    my $md5 = Digest::MD5-&gt;new;
    while (&lt;&gt;) {
	$md5-&gt;add($_);
	print &quot;Line $.: &quot;, $md5-&gt;clone-&gt;hexdigest, &quot;\n&quot;;
    }</code></pre>

</dd>
<dt id="$md5-&gt;add($data,...)"><a class="permalink" href="./Digest::MD5.html#$md5-%3Eadd($data,...)">#</a><a id="add"></a><a id="md5-add-data"></a>$md5-&gt;add($data,...)</dt>
<dd>

<p>The $data provided as argument are appended to the message we calculate the digest for. The return value is the $md5 object itself.</p>

<p>All these lines will have the same effect on the state of the $md5 object:</p>

<pre><code>$md5-&gt;add(&quot;a&quot;); $md5-&gt;add(&quot;b&quot;); $md5-&gt;add(&quot;c&quot;);
$md5-&gt;add(&quot;a&quot;)-&gt;add(&quot;b&quot;)-&gt;add(&quot;c&quot;);
$md5-&gt;add(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;);
$md5-&gt;add(&quot;abc&quot;);</code></pre>

</dd>
<dt id="$md5-&gt;addfile($io_handle)"><a class="permalink" href="./Digest::MD5.html#$md5-%3Eaddfile($io_handle)">#</a><a id="addfile"></a><a id="md5-addfile-io_handle"></a>$md5-&gt;addfile($io_handle)</dt>
<dd>

<p>The $io_handle will be read until EOF and its content appended to the message we calculate the digest for. The return value is the $md5 object itself.</p>

<p>The addfile() method will croak() if it fails reading data for some reason. If it croaks it is unpredictable what the state of the $md5 object will be in. The addfile() method might have been able to read the file partially before it failed. It is probably wise to discard or reset the $md5 object if this occurs.</p>

<p>In most cases you want to make sure that the $io_handle is in <code>binmode</code> before you pass it as argument to the addfile() method.</p>

</dd>
<dt id="$md5-&gt;add_bits($data,-$nbits)"><a class="permalink" href="./Digest::MD5.html#$md5-%3Eadd_bits($data,-$nbits)">#</a><a id="add_bits"></a><a id="md5-add_bits-data-nbits"></a>$md5-&gt;add_bits($data, $nbits)</dt>
<dd>

</dd>
<dt id="$md5-&gt;add_bits($bitstring)"><a class="permalink" href="./Digest::MD5.html#$md5-%3Eadd_bits($bitstring)">#</a><a id="add_bits1"></a><a id="md5-add_bits-bitstring"></a>$md5-&gt;add_bits($bitstring)</dt>
<dd>

<p>Since the MD5 algorithm is byte oriented you might only add bits as multiples of 8, so you probably want to just use add() instead. The add_bits() method is provided for compatibility with other digest implementations. See <a href="Digest.html">Digest</a> for description of the arguments that add_bits() take.</p>

</dd>
<dt id="$md5-&gt;digest"><a class="permalink" href="./Digest::MD5.html#$md5-%3Edigest">#</a><a id="digest"></a><a id="md5-digest"></a>$md5-&gt;digest</dt>
<dd>

<p>Return the binary digest for the message. The returned string will be 16 bytes long.</p>

<p>Note that the <code>digest</code> operation is effectively a destructive, read-once operation. Once it has been performed, the <code>Digest::MD5</code> object is automatically <code>reset</code> and can be used to calculate another digest value. Call $md5-&gt;clone-&gt;digest if you want to calculate the digest without resetting the digest state.</p>

</dd>
<dt id="$md5-&gt;hexdigest"><a class="permalink" href="./Digest::MD5.html#$md5-%3Ehexdigest">#</a><a id="hexdigest"></a><a id="md5-hexdigest"></a>$md5-&gt;hexdigest</dt>
<dd>

<p>Same as $md5-&gt;digest, but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: &#39;0&#39;..&#39;9&#39; and &#39;a&#39;..&#39;f&#39;.</p>

</dd>
<dt id="$md5-&gt;b64digest"><a class="permalink" href="./Digest::MD5.html#$md5-%3Eb64digest">#</a><a id="b64digest"></a><a id="md5-b64digest"></a>$md5-&gt;b64digest</dt>
<dd>

<p>Same as $md5-&gt;digest, but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: &#39;A&#39;..&#39;Z&#39;, &#39;a&#39;..&#39;z&#39;, &#39;0&#39;..&#39;9&#39;, &#39;+&#39; and &#39;/&#39;.</p>

<p>The base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md5 digests you might want to append the string &quot;==&quot; to the result.</p>

</dd>
<dt id="@ctx-=-$md5-&gt;context"><a class="permalink" href="./Digest::MD5.html#@ctx-=-$md5-%3Econtext">#</a><a id="ctx-md5-context"></a>@ctx = $md5-&gt;context</dt>
<dd>

</dd>
<dt id="$md5-&gt;context(@ctx)"><a class="permalink" href="./Digest::MD5.html#$md5-%3Econtext(@ctx)">#</a><a id="context"></a><a id="md5-context-ctx"></a>$md5-&gt;context(@ctx)</dt>
<dd>

<p>Saves or restores the internal state. When called with no arguments, returns a list: number of blocks processed, a 16-byte internal state buffer, then optionally up to 63 bytes of unprocessed data if there are any. When passed those same arguments, restores the state. This is only useful for specialised operations.</p>

</dd>
</dl>

<h1 id="EXAMPLES"><a class="permalink" href="./Digest::MD5.html#EXAMPLES">#</a>EXAMPLES</h1>

<p>The simplest way to use this library is to import the md5_hex() function (or one of its cousins):</p>

<pre><code>use Digest::MD5 qw(md5_hex);
print &quot;Digest is &quot;, md5_hex(&quot;foobarbaz&quot;), &quot;\n&quot;;</code></pre>

<p>The above example would print out the message:</p>

<pre><code class="plaintext">Digest is 6df23dc03f9b54cc38a0fc1483df6e21</code></pre>

<p>The same checksum can also be calculated in OO style:</p>

<pre><code>use Digest::MD5;

$md5 = Digest::MD5-&gt;new;
$md5-&gt;add(&#39;foo&#39;, &#39;bar&#39;);
$md5-&gt;add(&#39;baz&#39;);
$digest = $md5-&gt;hexdigest;

print &quot;Digest is $digest\n&quot;;</code></pre>

<p>With OO style, you can break the message arbitrarily. This means that we are no longer limited to have space for the whole message in memory, i.e. we can handle messages of any size.</p>

<p>This is useful when calculating checksum for files:</p>

<pre><code>use Digest::MD5;

my $filename = shift || &quot;/etc/passwd&quot;;
open (my $fh, &#39;&lt;&#39;, $filename) or die &quot;Can&#39;t open &#39;$filename&#39;: $!&quot;;
binmode($fh);

$md5 = Digest::MD5-&gt;new;
while (&lt;$fh&gt;) {
    $md5-&gt;add($_);
}
close($fh);
print $md5-&gt;b64digest, &quot; $filename\n&quot;;</code></pre>

<p>Or we can use the addfile method for more efficient reading of the file:</p>

<pre><code>use Digest::MD5;

my $filename = shift || &quot;/etc/passwd&quot;;
open (my $fh, &#39;&lt;&#39;, $filename) or die &quot;Can&#39;t open &#39;$filename&#39;: $!&quot;;
binmode ($fh);

print Digest::MD5-&gt;new-&gt;addfile($fh)-&gt;hexdigest, &quot; $filename\n&quot;;</code></pre>

<p>Since the MD5 algorithm is only defined for strings of bytes, it can not be used on strings that contains chars with ordinal number above 255 (Unicode strings). The MD5 functions and methods will croak if you try to feed them such input data:</p>

<pre><code>use Digest::MD5 qw(md5_hex);

my $str = &quot;abc\x{300}&quot;;
print md5_hex($str), &quot;\n&quot;;  # croaks
# Wide character in subroutine entry</code></pre>

<p>What you can do is calculate the MD5 checksum of the UTF-8 representation of such strings. This is achieved by filtering the string through encode_utf8() function:</p>

<pre><code>use Digest::MD5 qw(md5_hex);
use Encode qw(encode_utf8);

my $str = &quot;abc\x{300}&quot;;
print md5_hex(encode_utf8($str)), &quot;\n&quot;;
# 8c2d46911f3f5a326455f0ed7a8ed3b3</code></pre>

<h1 id="SEE-ALSO"><a class="permalink" href="./Digest::MD5.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<p><a href="Digest.html">Digest</a>, <a href="./Digest::MD2.html">Digest::MD2</a>, <a href="./Digest::SHA.html">Digest::SHA</a>, <a href="./Digest::HMAC.html">Digest::HMAC</a></p>

<p><a href="http://man.he.net/man1/md5sum">md5sum(1)</a></p>

<p>RFC 1321</p>

<p>http://en.wikipedia.org/wiki/MD5</p>

<p>The paper &quot;How to Break MD5 and Other Hash Functions&quot; by Xiaoyun Wang and Hongbo Yu.</p>

<h1 id="COPYRIGHT"><a class="permalink" href="./Digest::MD5.html#COPYRIGHT">#</a>COPYRIGHT</h1>

<p>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>

<pre><code class="plaintext">Copyright 1998-2003 Gisle Aas.
Copyright 1995-1996 Neil Winton.
Copyright 1991-1992 RSA Data Security, Inc.</code></pre>

<p>The MD5 algorithm is defined in RFC 1321. This implementation is derived from the reference C code in RFC 1321 which is covered by the following copyright statement:</p>

<ul>

<li><p>Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.</p>

<p>License to copy and use this software is granted provided that it is identified as the &quot;RSA Data Security, Inc. MD5 Message-Digest Algorithm&quot; in all material mentioning or referencing this software or this function.</p>

<p>License is also granted to make and use derivative works provided that such works are identified as &quot;derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm&quot; in all material mentioning or referencing the derived work.</p>

<p>RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided &quot;as is&quot; without express or implied warranty of any kind.</p>

<p>These notices must be retained in any copies of any part of this documentation and/or software.</p>

</li>
</ul>

<p>This copyright does not prohibit distribution of any version of Perl containing this extension under the terms of the GNU or Artistic licenses.</p>

<h1 id="AUTHORS"><a class="permalink" href="./Digest::MD5.html#AUTHORS">#</a>AUTHORS</h1>

<p>The original <code>MD5</code> interface was written by Neil Winton (<code>N.Winton@axion.bt.co.uk</code>).</p>

<p>The <code>Digest::MD5</code> module is written by Gisle Aas &lt;gisle@ActiveState.com&gt;.</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
